<?php
// wv-3.3 (c) 2008 by Alexander Klein, akx@gmx.net
// main

// send utf-8 header
header('Content-type: text/html; charset=utf-8');

// include config and class files
include 'config.php';
include 'WV_DataTable.class.php';
include 'WV_ShoutBox.class.php';
include 'WV_MainPage.class.php';

// disable error reporting
error_reporting(0);

// instantiate needed objects 
$wvDataTable = new WV_DataTable('wvsup.csv', $displayDays, $dataValues, $userList);
$wvShoutBox = new WV_ShoutBox('shout.csv');
$wvMainPage = new WV_MainPage('wvsup.html');

// main GET handler for Ajax responses
if (isset($_POST['action'])) {
	switch ($_POST['action']) {
		case 'loadTable':
			$wvDataTable->loadTable();
			break;
		case 'toggleCellValue':
			$wvDataTable->toggleCellValue($_POST['cellId']);
			break;	
		case 'postShout':
			$wvShoutBox->postShout($_POST['shoutText']);
			break;	
		case 'loadShoutbox':
			$wvShoutBox->loadShoutbox();
			break;	
		default:				
			$wvMainPage->showMainPage();
			break;
	}
}
else {
	// if no action is defined, the main page will be loaded
	$wvMainPage->showMainPage();
}
?>